package com.ruoyi.framework.web.service.proxy;

import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.domain.model.LoginUser;
import org.springframework.security.core.Authentication;

/**
 * @author ab785
 * createTime: 2021-12-9.
 * description: 微信扫码登录
 */
public class WechatScanLoginFlow extends LoginFlow {

    /**
     * 校验验证码
     *
     * @param loginBody 登录请求体
     */
    @Override
    void checkCaptcha(LoginBody loginBody) {
        String verifyKey = CacheConstants.CAPTCHA_WECHAT_SCAN_CODE_KEY + loginBody.getUuid();
        checkRedisCapture(loginBody, verifyKey);
    }

    @Override
    Authentication doLogin(LoginBody loginBody) {
        return userNameDirectLogin(loginBody);
    }

    @Override
    protected void onLoginSuccess(LoginUser loginUser) {
        System.out.println("微信扫码登录成功");
    }
}
